<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>尝试一下浏览器本地存储功能</title>
</head>
<body>
    <script>
        // 存入数据
        localStorage.setItem('key_one','这是存入的第一条数据')

        // 读取数据
        let result = localStorage.getItem('key_one')
        console.log(result)

        // 移除数据
        localStorage.removeItem('key_one')

        // 引用数据类型存入浏览器本地存储
        let obj = {
            name:'这是对象'
        }
        let arr = ['这是数组']

        localStorage.setItem('obj',JSON.stringify(obj))
        localStorage.setItem('arr',JSON.stringify(arr))

        result = localStorage.getItem('obj')
        console.log(JSON.parse(result))

        result = localStorage.getItem('arr')
        console.log(JSON.parse(result))
    </script>
</body>
</html>